package com.cloudlead.common.worker.web;

import com.cloudlead.common.lang.Configs;

import java.io.IOException;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerResponseContext;
import javax.ws.rs.container.ContainerResponseFilter;

public class AccessControlContainerResponseFilter implements ContainerResponseFilter {

	@Override
	public void filter(ContainerRequestContext requestContext, ContainerResponseContext responseContext) throws IOException {
		responseContext.getHeaders().add("Access-Control-Allow-Origin", Configs.getString("accessControl.allowOrigin"));
		responseContext.getHeaders().add("Access-Control-Allow-Methods", "GET,POST,PUT");
		responseContext.getHeaders().add("Access-Control-Allow-Headers", "Accept,Content-Type,Content-Length,Authorization");

	}

}
